<?php

//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');

require 'class.phpmailer.php';

////Create a new PHPMailer instance
//$mail = new PHPMailer();
////Tell PHPMailer to use SMTP
//$mail->IsSMTP();
////Enable SMTP debugging
//// 0 = off (for production use)
//// 1 = client messages
//// 2 = client and server messages
//$mail->SMTPDebug  = 2;
////Ask for HTML-friendly debug output
//$mail->Debugoutput = 'html';
//$mail->CharSet = 'UTF-8';
////Set the hostname of the mail server
//$mail->Host       = "smtp.126.com";
////Set the SMTP port number - likely to be 25, 465 or 587
//$mail->Port       = 25;
////Whether to use SMTP authentication
//$mail->SMTPAuth   = true;
////Username to use for SMTP authentication
//$mail->Username   = "923213904@qq.com";
////Password to use for SMTP authentication
//$mail->Password   = "zhouwuhua86";
////Set who the message is to be sent from
//$mail->SetFrom('923213904@qq.com', 'First Last');
////Set an alternative reply-to address
//$mail->AddReplyTo('923213904@qq.com','First Last');
////Set who the message is to be sent to
//$mail->AddAddress('294875286@qq.com', 'John Doe');
////Set the subject line
//$mail->Subject = 'PHPMailer SMTP test';
////$mail->Body = 'PHPMailer SMTP test';
////Read an HTML message body from an external file, convert referenced images to embedded, convert HTML into a basic plain-text alternative body
//$mail->MsgHTML(file_get_contents('contents.html'), dirname(__FILE__));
////$mail->MsgHTML('周围');
////Replace the plain text body with one created manually
////$mail->AltBody = 'This is a plain-text message body';
////Attach an image file
////$mail->AddAttachment('images/phpmailer-mini.gif');
//$mail->SMTPSecure = "ssl";
////Send the message, check for errors
//if(!$mail->Send()) {
//  echo "Mailer Error: " . $mail->ErrorInfo;
//} else {
//  echo "Message sent!";
//}
$address = '753455064@qq.com';
$subject = '欢迎光临想学网';
$body ='想学网测试服务器，请';
$altbody = '请使用兼容HTML格';
$mail = new PHPMailer();
$mail->IsSMTP(); //设置PHPMailer应用SMTP发送Email
$mail->CharSet = 'UTF-8';
$mail->Host = 'smtp.126.com';  // 指定邮件服务器
$mail->Port = 25;    //指定邮件服务器端口
$mail->SMTPAuth = true;     // 开启 SMTP验证
//设置SMTP用户名和密码
$mail->Username = 'liunian880716@126.com';
$mail->Password = 'zhouwuhua860808';
$mail->From = '294875286@qq.com'; //指定发送邮件地址
$mail->FromName = '想学网测试服务器'; //为发送邮件地址命名
//这里为批量发送邮件
if (is_array($address)) {
  foreach ($address as $val) {
    $mail->AddAddress($val);
  }
} else {
  $mail->AddAddress($address);
}
$mail->AddReplyTo('liunian880716@126.com', '大众影评网');
$mail->WordWrap = 50;   // 设置自动换行的字符长度为 50
$mail->IsHTML(true); // 设置Email格式为HTML
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AltBody = $altbody; //当收件人客户端不支持接收HTML格式email时的可替代内容;
//发送邮件。
if (!$mail->Send()) {
  $mail->ErrorInfo;
  return false;//throw_exception("Mailer Error: " . $mail->ErrorInfo);提示邮箱发送不成功的错误信息
} else {
  return true;
}

?>
